//
//  KyPageView.swift
//  KyPageViewDemo
//
//  Created by fangyukui on 2017/11/21.
//  Copyright © 2017年 fangyukui. All rights reserved.
//

import UIKit

class KyPageView: UIView {
    fileprivate var titles:[String]
    fileprivate var chirldVcs:[UIViewController]
    fileprivate var parentVc:UIViewController
    fileprivate var style:KyTitleStyle
    fileprivate var titleView:KyTitleView!
    fileprivate lazy var contentView:KyContentView = {
        let contentView = KyContentView(frame: CGRect(x: 0, y: self.style.titleHight, width: self.bounds.width, height: self.bounds.height - self.style.titleHight), childVcs: self.chirldVcs, parentVc: self.parentVc)
        return contentView
    }()
    
    init(frame: CGRect,titles:[String],chirldVcs:[UIViewController],parentVc:UIViewController,style:KyTitleStyle) {
        self.titles = titles
        self.chirldVcs = chirldVcs
        self.parentVc = parentVc
        self.style = style
        //在初始化之前必须对类属性初始化
        super.init(frame: frame)
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
extension KyPageView{
    fileprivate func  setupUI(){
        setupTitleView()
        setupContentView()
    }
    private func setupTitleView(){
        titleView = KyTitleView(frame: CGRect(x: 0, y: 0, width: bounds.width, height: style.titleHight), titles: titles, style: style)
        contentView.delegate = titleView
        addSubview(titleView)
        
        
    }
    private func setupContentView(){
        addSubview(contentView)
        titleView.deleagte = contentView
        
        
    }
    
}
